home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / msctsr.arc / POPUP.C next >
C/C++ Source or Header  |  1987-05-26  |  2KB  |  63 lines

  1. /* popup.c - Short demonstration of how to write "pop-up" utilities using
  2.  * Microsoft C version 4.0. Link this program with the object file of
  3.  * tsr.asm (also included in this ARC).
  4.  *
  5.  * The code in tsr.asm, written by Thomas Brandenborg of Denmark, is a
  6.  * very good example of how to write memory-resident "pop-up" utilities.
  7.  * It was adapted for use with Microsoft C 4.0 by myself, Paul Ketrick.
  8.  * I haven't had time to write a good demo of this library's capabilities
  9.  * (obviously), but it all does seem to work very well. However, if you
  10.  * have any problems with this code or find any bugs in it, I would
  11.  * appreciate your leaving me a short message about it on either the
  12.  * Programmer's Forum at (818)701-1021 or Mike's C BBS at (619)722-8724.
  13.  * You may use this code in any way you see fit, but please give me credit
  14.  * for it in your source code (and the object too, if you want). Also see
  15.  * Mr. Brandenborg's copyright notice in the other file.
  16.  */
  17.  
  18. #include <stdio.h>
  19. #include <ctype.h>
  20.  
  21. main()
  22. {
  23.     printf("Installing Pop-up TSR code...\n");
  24.     init();                            /* Call a/l routine to install            */
  25.                                     /* memory-resident pop-up utility        */
  26.                                     /* (does not return to caller)            */
  27. }
  28.  
  29. /* popup() is called by the code in tsr.asm which intercepts keyboard
  30.  * interrupts and watches for the "hot key." It may safely use any DOS
  31.  * functions including console I/O, file I/O, etc. and may use any C
  32.  * library functions EXCEPT dynamic memory allocation in the default (near)
  33.  * data segment. In order to use these functions, a small change must be
  34.  * made to tsr.asm - see process _Init in that file for more information.
  35.  */
  36.  
  37. popup()
  38. {
  39.     int i;
  40.  
  41.     for (;;)  {
  42.         printf("\nPop-Up Program:\n");
  43.         printf("A - ASCII table\n");
  44.         printf("N - Notepad\n");
  45.         printf("X - Exit.\n");
  46.  
  47.         i = getchar();
  48.         switch(toupper(i))  {
  49.             case 'A':
  50.                 printf("Sorry, ASCII table unavailable.\n");
  51.                 break;
  52.  
  53.             case 'N':
  54.                 printf("Sorry, notepad unavailable.\n");
  55.                 break;
  56.  
  57.             case 'X':
  58.                 printf("Exiting Pop-up.\n");
  59.                 return;
  60.         }
  61.     }
  62. }
  63.